package com.passer.simpletransfer.controller;

import com.passer.simpletransfer.contant.Browser;
import com.passer.simpletransfer.service.BrowserBookmarkService;
import com.passer.simpletransfer.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/tool/browser")
public class ToolBrowserController {
    private final BrowserBookmarkService bookmarkService;


    @Autowired
    public ToolBrowserController(BrowserBookmarkService bookmarkService) {
        this.bookmarkService = bookmarkService;
    }

    @GetMapping("/edgeBookmarkExport")
    public ResponseVo bookmarkExport(@RequestParam("browser") Browser browser) {
        ResponseVo responseVo = new ResponseVo();
        try {
            responseVo.setData(bookmarkService.bookmarkExport(browser));
        } catch (Exception e) {
            responseVo.setRespCode(500);
            responseVo.setMsg(e.getMessage());
        }
        responseVo.setRespCode(200);
        return responseVo;
    }
}
